#ifndef FACTORIES_H
#define FACTORIES_H

#include "vecmath.h"
#include "Singleton.h"
#include "vertexarray.h"

class ObjectFactory : public Singleton<ObjectFactory>
{
public:
    VertexArray* createRectangle(Vec3f min, Vec3f max, Color4b color);
};

class ColorFactory : public Singleton<ColorFactory>
{
public:
    ColorFactory() { setDefaultColors(); registerColorKeys(); loadColorProfile(); }
    
    void setDefaultColors();
	void registerColorKeys();
	
	void getColor(Color4b out, const QString& category, const QString& key);
	void setColor(Color4b in, const QString& category, const QString& key);
	QList<QString> getCategories() const { return keyColorMap.keys(); }
	QList<QString> getColorKeys(const QString& category) const { return (keyColorMap[category]).keys(); }
	
	void saveColorProfile(const QString& path = "ColorProfile.xml") const;
	void loadColorProfile(const QString& path = "ColorProfile.xml");
    
    void getBackgroundColor(Color4b out) { SetColor4b(out, backgroundColor); }
    const GLubyte* getBackgroundColor() { return backgroundColor; }
    
    void getSelectionColor(Color4b out) { SetColor4b(out, selectionColor); }
    const GLubyte* getSelectionColor() { return selectionColor; }
    
    void getTextColor(Color4b out) { SetColor4b(out, textColor); }
    const GLubyte* getTextColor() { return textColor; }
	
	void getListColor(Color4b out) { SetColor4b(out, listColor); }
	const GLubyte* getListColor() { return listColor; }
    
	void getStateColor(Color4b out) { SetColor4b(out, stateColor); }
	const GLubyte* getStateColor() { return stateColor; }
	
	void getContainerColor(Color4b out) { SetColor4b(out, containerColor); }
	const GLubyte* getContainerColor() { return containerColor; }
    
	void getContainerSelecteedColor(Color4b out) { SetColor4b(out, containerSelectedColor); }
	const GLubyte* getContainerSelectedColor() { return containerSelectedColor; }
    
	void getContainerBorderColor(Color4b out) { SetColor4b(out, containerBorderColor); }
	const GLubyte* getContainerBorderColor() { return containerBorderColor; }
    
	void getGridLabelColor(Color4b out) { SetColor4b(out, gridLabelColor); }
	const GLubyte* getGridLabelColor() { return gridLabelColor; }
    
	void getGridBackgroundColor(Color4b out) { SetColor4b(out, gridBackgroundColor); }
	const GLubyte* getGridBackgroundColor() { return gridBackgroundColor; }
    
	void getGridBackgroundBorderColor(Color4b out) { SetColor4b(out, gridBackgroundBorderColor); }
	const GLubyte* getGridBackgroundBorderColor() { return gridBackgroundBorderColor; }
	
protected:
	QMap<QString, QMap<QString, Color4b*> > keyColorMap;
	
private:
    Color4b backgroundColor;
    Color4b selectionColor;
    Color4b textColor;
	Color4b listColor;
	Color4b stateColor;
	Color4b containerColor;
	Color4b containerSelectedColor;
	Color4b containerBorderColor;
	Color4b gridLabelColor;
	Color4b gridBackgroundColor;
	Color4b gridBackgroundBorderColor;
    
    static Color4b defaultBackgroundColor;
    static Color4b defaultSelectionColor;
    static Color4b defaultTextColor;
	static Color4b defaultListColor;
	static Color4b defaultStateColor;
	static Color4b defaultContainerColor;
	static Color4b defaultContainerSelectedColor;
	static Color4b defaultContainerBorderColor;
	static Color4b defaultGridLabelColor;
	static Color4b defaultGridBackgroundColor;
	static Color4b defaultGridBackgroundBorderColor;
};

#endif // FACTORIES_H
